#ifndef FANCTRL_H
#define FANCTRL_H

//初始化调用: FanCtrlInit();
//主循环调用: 
//  HeatingFanCtrl();
//  ExhaustFanCtrl();
//  IgniterCtrl();
//定时器 Tick 10ms调用: FanCtrlClock();
//控制所有温控设备准备工作: FanCtrlStart();
//控制所有温控设备停止工作: FanCtrlStop();


#define SmokeTempSetting 180 //°F
#define HighTempSetting 450  //°F
#define SmokeTempMeatSetting 140 //°F
#define HighTempMeatSetting 215 //°F

//原理图上: 输出高电平风扇停止, 输出低电平风扇运行
#define IgniterOpen GPIO_Write_Low(GPIOA0,IO_Heater); //开始加热点火输出 (紫色线)
#define IgniterClose GPIO_Write_High(GPIOA0,IO_Heater); //停止加热点火输出
#define HeaterFanOpen GPIO_Write_Low(GPIOA0,IO_Feed); //开始进料加热输出 (红色线)
#define HeaterFanClose GPIO_Write_High(GPIOA0,IO_Feed); //停止进料加热输出
#define ExhaustFanOpen GPIO_Write_Low(GPIOB0,IO_Fan); //开始排气扇输出 (橙色线)
#define ExhaustFanClose GPIO_Write_High(GPIOB0,IO_Fan); //停止排气扇输出

#define FanClose_CountDown 600 //切换到Shut Down档位后,排气扇打开持续该时间后关闭
#define FanClose_Delay_Time (FanClose_CountDown) //10s,用于显示OFF的时间,闪耀4次


//以下两个参数,需要提供
extern uint16_t temp_set;
extern uint8_t Smoke_P_Value;
extern uint8_t IgniterStep;
extern uint8_t HeatingFanStep;
extern uint16_t ExhaustFanClock; //if(ExhaustFanClock > 0) 显示OFF跟关机倒计时

#if Debug_Hand_PID == 1
extern float Hand_PID_TD;
#endif

void FanCtrlInit(void);
void FanCtrlClock(void);
void FanCtrlStart(void);
void FanCtrlStop(void);
void FanCtrlForceStop(void);
void HeatingFanCtrl(void);
void ExhaustFanCtrl(void);
void IgniterCtrl(void);

#endif
